package com.cn.hotel.dao.Impl;

import com.cn.hotel.dao.ICompanyInformationDao;
import com.cn.hotel.model.CompanyInformationModel;
import com.cn.hotel.model.NavModel;
import com.cn.hotel.util.JDBC;

import java.sql.ResultSet;
import java.sql.SQLException;

public class CompanyInformationImpl implements ICompanyInformationDao {
    /**
     * 前端获取公司信息逻辑代码实现
     * @return
     */
    @Override
    public CompanyInformationModel getCompanyInformationModel() {
        StringBuilder sql = new StringBuilder("SELECT company.*,company_contact.*  FROM company,company_contact WHERE company.id = company_contact.id;");
        ResultSet resultSet = JDBC.getResultSet(sql.toString());
        CompanyInformationModel model = new CompanyInformationModel();
        try {
            while (resultSet.next()) {
                model.setLogo(resultSet.getString("logo"));
                model.setAddress(resultSet.getString("company_adress"));
                model.setEmail(resultSet.getString("company_email"));
                model.setPhone(resultSet.getString("company_phone"));
                model.setFax(resultSet.getString("company_fax"));
                model.setIntroduce(resultSet.getString("introduce"));
                model.setQrCode(resultSet.getString("qr_code"));
                model.setVersion(resultSet.getString("version"));
                model.setNet(resultSet.getString("net"));
                model.setAd(resultSet.getString("ad"));
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return model;
    }

}
